{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import torch\n",
    "import torch.autograd as autograd\n",
    "import torch.nn as nn\n",
    "import torch.nn.functional as F\n",
    "import torch.optim as optim\n",
    "import torch.utils.data as Data\n",
    "torch.manual_seed(8)\n",
    "\n",
    "import time\n",
    "import numpy as np\n",
    "import gc\n",
    "import sys\n",
    "sys.setrecursionlimit(50000)\n",
    "import pickle\n",
    "torch.backends.cudnn.benchmark = True\n",
    "torch.set_default_tensor_type('torch.cuda.FloatTensor')\n",
    "# from tensorboardX import SummaryWriter\n",
    "torch.nn.Module.dump_patches = True\n",
    "import copy\n",
    "import pandas as pd\n",
    "#then import my own modules\n",
    "from AttentiveFP import Fingerprint, Fingerprint_viz, save_smiles_dicts, get_smiles_dicts, get_smiles_array, moltosvg_highlight"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from rdkit import Chem\n",
    "# from rdkit.Chem import AllChem\n",
    "from rdkit.Chem import QED\n",
    "from rdkit.Chem import rdMolDescriptors, MolSurf\n",
    "from rdkit.Chem.Draw import SimilarityMaps\n",
    "from rdkit import Chem\n",
    "from rdkit.Chem import AllChem\n",
    "from rdkit.Chem import rdDepictor\n",
    "from rdkit.Chem.Draw import rdMolDraw2D\n",
    "%matplotlib inline\n",
    "from numpy.polynomial.polynomial import polyfit\n",
    "import matplotlib.pyplot as plt\n",
    "from matplotlib import gridspec\n",
    "import matplotlib.cm as cm\n",
    "import matplotlib\n",
    "import seaborn as sns; sns.set_style(\"darkgrid\")\n",
    "from IPython.display import SVG, display\n",
    "import sascorer\n",
    "import itertools\n",
    "from sklearn.metrics import r2_score\n",
    "import scipy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "random_seed = 108 \n",
    "start_time = str(time.ctime()).replace(':','-').replace(' ','_')\n",
    "\n",
    "batch_size = 200\n",
    "epochs = 200\n",
    "\n",
    "p_dropout= 0.2\n",
    "fingerprint_dim = 200\n",
    "\n",
    "weight_decay = 5 # also known as l2_regularization_lambda\n",
    "learning_rate = 2.5\n",
    "output_units_num = 1 # for regression model\n",
    "radius = 2\n",
    "T = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "number of all smiles:  1128\n",
      "number of successfully processed smiles:  1128\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAU8AAAC/CAYAAAB+KF5fAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEx1JREFUeJzt3Xtsk9f9x/FPnIQQSIg7ZoG4bGsbHNWkJN0IFxWRjRLSTrRROjZKtZZobOmmRWNrworawTqEdiEZ0KVCdCBU6FUVaqGQCrY0KtNKxtAqNrpC7IJaoVaEAHFCSDFJ7N8f++HVs+PYB18S5/2SIuFzvn58fEg+fvzYz3nSfD6fTwCAqFiSPQAAGIkITwAwQHgCgAHCEwAMEJ4AYIDwBAADhCcAGCA8AcAA4QkABghPADBAeAKAAcITAAwQngBgICPZA4iFzs6r8npDLw41cWKOLl3qSfCIRi/mO/GY85tjsaTpllvGR32/lAhPr9c3aHje6EfiMN+Jx5wnHm/bAcAA4QkABghPADBAeAKAgZT4wGi46vdKnr7+sDVZmRnK4CUMGHEIzzjy9PXr+Kn2sDUld0xSRhb/DcBIwz4PABggPAHAAOEJAAYITwAwQHgCgAHCEwAMEJ4AYIDwBAADhCcAGCA8AcBAROcFnj9/Xjt37tS///1vnT59Wr29vdqzZ4/mzp0bULdo0SJ98sknQff/wQ9+oLq6uoC2ixcvqr6+Xu+88448Ho8cDofq6ur01a9+9Sa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xIpa7i41nn31W27Zt0+rVq/X9738/qH/y5MkqLCzUgQMHtHLlSv8Hd62trWpvb9eSJUsSPeQR60tf+pL27NkT1P7rX/9avb292rhxo6ZMmcKcJ0nKLQzi8/m0cuVKtbW1ac2aNf7l7vbt26dt27Zp0aJFyR7iiLVr1y797ne/0ze+8Q398Ic/DOgbM2aMHA6HpP/80a5atUpLlizR8uXL1d7eroaGBk2ZMkWvvPKK0tPTkzH8lPHII4+ou7tb+/fv97cx54mXcuEpsdxdvDzyyCP6+9//HrJv6tSpAYtb/+Uvf1FjY6NOnz6t8ePHa/HixVqzZg3H32IgVHhKzHmipWR4AkC8pdwHRgCQCIQnABggPAHAAOEJAAYITwAwQHgCgAHCEwAMEJ4AYIDwBAAD/wdyKveHcnpZxgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 360x216 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "task_name = 'solubility'\n",
    "tasks = ['measured log solubility in mols per litre']\n",
    "\n",
    "raw_filename = \"../data/delaney-processed.csv\"\n",
    "feature_filename = raw_filename.replace('.csv','.pickle')\n",
    "filename = raw_filename.replace('.csv','')\n",
    "prefix_filename = raw_filename.split('/')[-1].replace('.csv','')\n",
    "smiles_tasks_df = pd.read_csv(raw_filename)\n",
    "smilesList = smiles_tasks_df.smiles.values\n",
    "print(\"number of all smiles: \",len(smilesList))\n",
    "atom_num_dist = []\n",
    "remained_smiles = []\n",
    "canonical_smiles_list = []\n",
    "for smiles in smilesList:\n",
    "    try:        \n",
    "        mol = Chem.MolFromSmiles(smiles)\n",
    "        atom_num_dist.append(len(mol.GetAtoms()))\n",
    "        remained_smiles.append(smiles)\n",
    "        canonical_smiles_list.append(Chem.MolToSmiles(Chem.MolFromSmiles(smiles), isomericSmiles=True))\n",
    "    except:\n",
    "        print(smiles)\n",
    "        pass\n",
    "print(\"number of successfully processed smiles: \", len(remained_smiles))\n",
    "smiles_tasks_df = smiles_tasks_df[smiles_tasks_df[\"smiles\"].isin(remained_smiles)]\n",
    "# print(smiles_tasks_df)\n",
    "smiles_tasks_df['cano_smiles'] =canonical_smiles_list\n",
    "\n",
    "plt.figure(figsize=(5, 3))\n",
    "sns.set(font_scale=1.5)\n",
    "ax = sns.distplot(atom_num_dist, bins=28, kde=False)\n",
    "plt.tight_layout()\n",
    "# plt.savefig(\"atom_num_dist_\"+prefix_filename+\".png\",dpi=200)\n",
    "plt.show()\n",
    "plt.close()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "not processed items\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Compound ID</th>\n",
       "      <th>ESOL predicted log solubility in mols per litre</th>\n",
       "      <th>Minimum Degree</th>\n",
       "      <th>Molecular Weight</th>\n",
       "      <th>Number of H-Bond Donors</th>\n",
       "      <th>Number of Rings</th>\n",
       "      <th>Number of Rotatable Bonds</th>\n",
       "      <th>Polar Surface Area</th>\n",
       "      <th>measured log solubility in mols per litre</th>\n",
       "      <th>smiles</th>\n",
       "      <th>cano_smiles</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>934</th>\n",
       "      <td>Methane</td>\n",
       "      <td>-0.636</td>\n",
       "      <td>0</td>\n",
       "      <td>16.043</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>-0.9</td>\n",
       "      <td>C</td>\n",
       "      <td>C</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Compound ID  ESOL predicted log solubility in mols per litre  \\\n",
       "934     Methane                                           -0.636   \n",
       "\n",
       "     Minimum Degree  Molecular Weight  Number of H-Bond Donors  \\\n",
       "934               0            16.043                        0   \n",
       "\n",
       "     Number of Rings  Number of Rotatable Bonds  Polar Surface Area  \\\n",
       "934                0                          0                 0.0   \n",
       "\n",
       "     measured log solubility in mols per litre smiles cano_smiles  \n",
       "934                                       -0.9      C           C  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "if os.path.isfile(feature_filename):\n",
    "    feature_dicts = pickle.load(open(feature_filename, \"rb\" ))\n",
    "else:\n",
    "    feature_dicts = save_smiles_dicts(smilesList,filename)\n",
    "# feature_dicts = get_smiles_dicts(smilesList)\n",
    "remained_df = smiles_tasks_df[smiles_tasks_df[\"cano_smiles\"].isin(feature_dicts['smiles_to_atom_mask'].keys())]\n",
    "uncovered_df = smiles_tasks_df.drop(remained_df.index)\n",
    "print(\"not processed items\")\n",
    "uncovered_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "remained_df = remained_df.reset_index(drop=True)\n",
    "test_df = remained_df.sample(frac=1/10, random_state=random_seed) # test set\n",
    "training_data = remained_df.drop(test_df.index) # training data\n",
    "\n",
    "# training data is further divided into validation set and train set\n",
    "valid_df = training_data.sample(frac=1/9, random_state=random_seed) # validation set\n",
    "train_df = training_data.drop(valid_df.index) # train set\n",
    "train_df = train_df.reset_index(drop=True)\n",
    "valid_df = valid_df.reset_index(drop=True)\n",
    "test_df = test_df.reset_index(drop=True)\n",
    "\n",
    "# print(len(test_df),sorted(test_df.cano_smiles.values))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Compound ID</th>\n",
       "      <th>ESOL predicted log solubility in mols per litre</th>\n",
       "      <th>Minimum Degree</th>\n",
       "      <th>Molecular Weight</th>\n",
       "      <th>Number of H-Bond Donors</th>\n",
       "      <th>Number of Rings</th>\n",
       "      <th>Number of Rotatable Bonds</th>\n",
       "      <th>Polar Surface Area</th>\n",
       "      <th>measured log solubility in mols per litre</th>\n",
       "      <th>smiles</th>\n",
       "      <th>cano_smiles</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1-Chlorobutane</td>\n",
       "      <td>-1.940</td>\n",
       "      <td>1</td>\n",
       "      <td>92.569</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-2.030</td>\n",
       "      <td>CCCCCl</td>\n",
       "      <td>CCCCCl</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2,6-Dimethylphenol</td>\n",
       "      <td>-2.589</td>\n",
       "      <td>1</td>\n",
       "      <td>122.167</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>20.23</td>\n",
       "      <td>-1.290</td>\n",
       "      <td>Cc1cccc(C)c1O</td>\n",
       "      <td>Cc1cccc(C)c1O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>RTI 24</td>\n",
       "      <td>-4.423</td>\n",
       "      <td>1</td>\n",
       "      <td>273.723</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>45.23</td>\n",
       "      <td>-5.360</td>\n",
       "      <td>CCN2c1cc(Cl)ccc1NC(=O)c3cccnc23</td>\n",
       "      <td>CCN1c2cc(Cl)ccc2NC(=O)c2cccnc21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1-Dodecanol</td>\n",
       "      <td>-3.523</td>\n",
       "      <td>1</td>\n",
       "      <td>186.339</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>10</td>\n",
       "      <td>20.23</td>\n",
       "      <td>-4.800</td>\n",
       "      <td>CCCCCCCCCCCCO</td>\n",
       "      <td>CCCCCCCCCCCCO</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3-Pentanol</td>\n",
       "      <td>-0.970</td>\n",
       "      <td>1</td>\n",
       "      <td>88.150</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>20.23</td>\n",
       "      <td>-0.240</td>\n",
       "      <td>CCC(O)CC</td>\n",
       "      <td>CCC(O)CC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Dimefuron</td>\n",
       "      <td>-3.831</td>\n",
       "      <td>1</td>\n",
       "      <td>338.795</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>80.37</td>\n",
       "      <td>-4.328</td>\n",
       "      <td>CN(C)C(=O)Nc1ccc(c(Cl)c1)n2nc(oc2=O)C(C)(C)C</td>\n",
       "      <td>CN(C)C(=O)Nc1ccc(-n2nc(C(C)(C)C)oc2=O)c(Cl)c1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>8-quinolinol</td>\n",
       "      <td>-2.725</td>\n",
       "      <td>1</td>\n",
       "      <td>145.161</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>33.12</td>\n",
       "      <td>-2.420</td>\n",
       "      <td>Oc1cccc2cccnc12</td>\n",
       "      <td>Oc1cccc2cccnc12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>Fenitrothion</td>\n",
       "      <td>-3.845</td>\n",
       "      <td>1</td>\n",
       "      <td>277.238</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>70.83</td>\n",
       "      <td>-4.040</td>\n",
       "      <td>COP(=S)(OC)Oc1ccc(N(=O)=O)c(C)c1</td>\n",
       "      <td>COP(=S)(OC)Oc1ccc([N+](=O)[O-])c(C)c1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>Tetradecane</td>\n",
       "      <td>-5.450</td>\n",
       "      <td>1</td>\n",
       "      <td>198.394</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-7.960</td>\n",
       "      <td>CCCCCCCCCCCCCC</td>\n",
       "      <td>CCCCCCCCCCCCCC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>4-hydroxypyridine</td>\n",
       "      <td>-1.655</td>\n",
       "      <td>1</td>\n",
       "      <td>95.101</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>33.12</td>\n",
       "      <td>1.020</td>\n",
       "      <td>Oc1ccncc1</td>\n",
       "      <td>Oc1ccncc1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>Pyrolan</td>\n",
       "      <td>-3.141</td>\n",
       "      <td>1</td>\n",
       "      <td>245.282</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>47.36</td>\n",
       "      <td>-2.090</td>\n",
       "      <td>CN(C)C(=O)Oc1cc(C)nn1c2ccccc2</td>\n",
       "      <td>Cc1cc(OC(=O)N(C)C)n(-c2ccccc2)n1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>Androsterone</td>\n",
       "      <td>-3.882</td>\n",
       "      <td>1</td>\n",
       "      <td>290.447</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>37.30</td>\n",
       "      <td>-4.402</td>\n",
       "      <td>CC12CCC(O)CC1CCC3C2CCC4(C)C3CCC4=O</td>\n",
       "      <td>CC12CCC3C(CCC4CC(O)CCC43C)C1CCC2=O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>Styrene</td>\n",
       "      <td>-2.850</td>\n",
       "      <td>1</td>\n",
       "      <td>104.152</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-2.820</td>\n",
       "      <td>C=Cc1ccccc1</td>\n",
       "      <td>C=Cc1ccccc1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>Erythritol</td>\n",
       "      <td>0.675</td>\n",
       "      <td>1</td>\n",
       "      <td>122.120</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>80.92</td>\n",
       "      <td>0.700</td>\n",
       "      <td>OCC(O)C(O)CO</td>\n",
       "      <td>OCC(O)C(O)CO</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>1-Tetradecanol</td>\n",
       "      <td>-4.231</td>\n",
       "      <td>1</td>\n",
       "      <td>214.393</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>12</td>\n",
       "      <td>20.23</td>\n",
       "      <td>-5.840</td>\n",
       "      <td>CCCCCCCCCCCCCCO</td>\n",
       "      <td>CCCCCCCCCCCCCCO</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>Butyraldehyde</td>\n",
       "      <td>-0.749</td>\n",
       "      <td>1</td>\n",
       "      <td>72.107</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>17.07</td>\n",
       "      <td>-0.010</td>\n",
       "      <td>CCCC=O</td>\n",
       "      <td>CCCC=O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>1,2,4,5-Tetramethylbenzene</td>\n",
       "      <td>-3.664</td>\n",
       "      <td>1</td>\n",
       "      <td>134.222</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-4.590</td>\n",
       "      <td>Cc1cc(C)c(C)cc1C</td>\n",
       "      <td>Cc1cc(C)c(C)cc1C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>Coumachlor</td>\n",
       "      <td>-4.554</td>\n",
       "      <td>1</td>\n",
       "      <td>342.778</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>67.51</td>\n",
       "      <td>-5.839</td>\n",
       "      <td>CC(=O)CC(c1ccc(Cl)cc1)c2c(O)c3ccccc3oc2=O</td>\n",
       "      <td>CC(=O)CC(c1ccc(Cl)cc1)c1c(O)c2ccccc2oc1=O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>Fenarimol</td>\n",
       "      <td>-4.108</td>\n",
       "      <td>1</td>\n",
       "      <td>331.202</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>46.01</td>\n",
       "      <td>-4.380</td>\n",
       "      <td>OC(c1ccc(Cl)cc1)(c2cncnc2)c3ccccc3Cl</td>\n",
       "      <td>OC(c1ccc(Cl)cc1)(c1cncnc1)c1ccccc1Cl</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>hydrochlorothiazide</td>\n",
       "      <td>-1.720</td>\n",
       "      <td>1</td>\n",
       "      <td>297.745</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>118.36</td>\n",
       "      <td>-2.630</td>\n",
       "      <td>NS(=O)(=O)c2cc1c(NCNS1(=O)=O)cc2Cl</td>\n",
       "      <td>NS(=O)(=O)c1cc2c(cc1Cl)NCNS2(=O)=O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>Methyl nonanoate</td>\n",
       "      <td>-2.962</td>\n",
       "      <td>1</td>\n",
       "      <td>172.268</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>26.30</td>\n",
       "      <td>-3.380</td>\n",
       "      <td>CCCCCCCCC(=O)OC</td>\n",
       "      <td>CCCCCCCCC(=O)OC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>meconin</td>\n",
       "      <td>-0.825</td>\n",
       "      <td>1</td>\n",
       "      <td>196.202</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>44.76</td>\n",
       "      <td>-1.899</td>\n",
       "      <td>c1c(OC)c(OC)C2C(=O)OCC2c1</td>\n",
       "      <td>COC1=C(OC)C2C(=O)OCC2C=C1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1-Hexene</td>\n",
       "      <td>-2.364</td>\n",
       "      <td>1</td>\n",
       "      <td>84.162</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-3.230</td>\n",
       "      <td>CCCCC=C</td>\n",
       "      <td>C=CCCCC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>Glutethimide</td>\n",
       "      <td>-2.591</td>\n",
       "      <td>1</td>\n",
       "      <td>217.268</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>46.17</td>\n",
       "      <td>-2.337</td>\n",
       "      <td>CCC1(CCC(=O)NC1=O)c2ccccc2</td>\n",
       "      <td>CCC1(c2ccccc2)CCC(=O)NC1=O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>3-Methyl-3-hexanol</td>\n",
       "      <td>-1.663</td>\n",
       "      <td>1</td>\n",
       "      <td>116.204</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>20.23</td>\n",
       "      <td>-0.980</td>\n",
       "      <td>CCCC(C)(O)CC</td>\n",
       "      <td>CCCC(C)(O)CC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>4-Ethyltoluene</td>\n",
       "      <td>-3.328</td>\n",
       "      <td>1</td>\n",
       "      <td>120.195</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-3.110</td>\n",
       "      <td>CCc1ccc(C)cc1</td>\n",
       "      <td>CCc1ccc(C)cc1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>metharbital</td>\n",
       "      <td>-1.658</td>\n",
       "      <td>1</td>\n",
       "      <td>198.222</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>66.48</td>\n",
       "      <td>-2.230</td>\n",
       "      <td>CCC1(CC)C(=O)NC(=O)N(C)C1=O</td>\n",
       "      <td>CCC1(CC)C(=O)NC(=O)N(C)C1=O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>Piperophos</td>\n",
       "      <td>-4.637</td>\n",
       "      <td>1</td>\n",
       "      <td>353.490</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>9</td>\n",
       "      <td>38.77</td>\n",
       "      <td>-4.150</td>\n",
       "      <td>CCCOP(=S)(OCCC)SCC(=O)N1CCCCC1C</td>\n",
       "      <td>CCCOP(=S)(OCCC)SCC(=O)N1CCCCC1C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>Bromoethane</td>\n",
       "      <td>-1.529</td>\n",
       "      <td>1</td>\n",
       "      <td>108.966</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-1.090</td>\n",
       "      <td>CCBr</td>\n",
       "      <td>CCBr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>3-Octanol</td>\n",
       "      <td>-2.033</td>\n",
       "      <td>1</td>\n",
       "      <td>130.231</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>20.23</td>\n",
       "      <td>-1.980</td>\n",
       "      <td>CCCCCC(O)CC</td>\n",
       "      <td>CCCCCC(O)CC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>83</th>\n",
       "      <td>thiamylal</td>\n",
       "      <td>-3.063</td>\n",
       "      <td>1</td>\n",
       "      <td>254.355</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>58.20</td>\n",
       "      <td>-3.460</td>\n",
       "      <td>CCCC(C)C1(CC=C)C(=O)NC(=S)NC1=O</td>\n",
       "      <td>C=CCC1(C(C)CCC)C(=O)NC(=S)NC1=O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>84</th>\n",
       "      <td>Diisopropylsulfide</td>\n",
       "      <td>-2.162</td>\n",
       "      <td>1</td>\n",
       "      <td>118.245</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-2.240</td>\n",
       "      <td>CC(C)SC(C)C</td>\n",
       "      <td>CC(C)SC(C)C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>85</th>\n",
       "      <td>Procymidone</td>\n",
       "      <td>-3.464</td>\n",
       "      <td>1</td>\n",
       "      <td>284.142</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>37.38</td>\n",
       "      <td>-4.800</td>\n",
       "      <td>CC12CC2(C)C(=O)N(C1=O)c3cc(Cl)cc(Cl)c3</td>\n",
       "      <td>CC12CC1(C)C(=O)N(c1cc(Cl)cc(Cl)c1)C2=O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>1-Bromobutane</td>\n",
       "      <td>-2.303</td>\n",
       "      <td>1</td>\n",
       "      <td>137.020</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-2.370</td>\n",
       "      <td>CCCCBr</td>\n",
       "      <td>CCCCBr</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>1,2-Diethoxyethane</td>\n",
       "      <td>-0.833</td>\n",
       "      <td>1</td>\n",
       "      <td>118.176</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>18.46</td>\n",
       "      <td>-0.770</td>\n",
       "      <td>CCOCCOCC</td>\n",
       "      <td>CCOCCOCC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>Thalidomide</td>\n",
       "      <td>-1.944</td>\n",
       "      <td>1</td>\n",
       "      <td>258.233</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>83.55</td>\n",
       "      <td>-2.676</td>\n",
       "      <td>O=C1N(C2CCC(=O)NC2=O)C(=O)c3ccccc13</td>\n",
       "      <td>O=C1CCC(N2C(=O)c3ccccc3C2=O)C(=O)N1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>1-Pentene</td>\n",
       "      <td>-2.010</td>\n",
       "      <td>1</td>\n",
       "      <td>70.135</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-2.680</td>\n",
       "      <td>CCCC=C</td>\n",
       "      <td>C=CCCC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>Propetamphos</td>\n",
       "      <td>-2.826</td>\n",
       "      <td>1</td>\n",
       "      <td>281.314</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>56.79</td>\n",
       "      <td>-3.408</td>\n",
       "      <td>CCNP(=S)(OC)OC(=CC(=O)OC(C)C)C</td>\n",
       "      <td>CCNP(=S)(OC)OC(C)=CC(=O)OC(C)C</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>triamcinolone diacetate</td>\n",
       "      <td>-3.876</td>\n",
       "      <td>1</td>\n",
       "      <td>478.513</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>127.20</td>\n",
       "      <td>-4.130</td>\n",
       "      <td>CC(=O)OCC(=O)C3(O)C(CC4C2CCC1=CC(=O)C=CC1(C)C2...</td>\n",
       "      <td>CC(=O)OCC(=O)C1(O)C(OC(C)=O)CC2C3CCC4=CC(=O)C=...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>92</th>\n",
       "      <td>4-Pentene-1-ol</td>\n",
       "      <td>-0.791</td>\n",
       "      <td>1</td>\n",
       "      <td>86.134</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>20.23</td>\n",
       "      <td>-0.150</td>\n",
       "      <td>OCCCC=C</td>\n",
       "      <td>C=CCCCO</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>93</th>\n",
       "      <td>3-Methylheptane</td>\n",
       "      <td>-3.308</td>\n",
       "      <td>1</td>\n",
       "      <td>114.232</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-5.160</td>\n",
       "      <td>CCCCC(C)CC</td>\n",
       "      <td>CCCCC(C)CC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>94</th>\n",
       "      <td>o-Chlorobromobenzene</td>\n",
       "      <td>-3.840</td>\n",
       "      <td>1</td>\n",
       "      <td>191.455</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-3.190</td>\n",
       "      <td>Clc1ccccc1Br</td>\n",
       "      <td>Clc1ccccc1Br</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95</th>\n",
       "      <td>cycloate</td>\n",
       "      <td>-3.350</td>\n",
       "      <td>1</td>\n",
       "      <td>215.362</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>20.31</td>\n",
       "      <td>-3.400</td>\n",
       "      <td>CCSC(=O)N(CC)C1CCCCC1</td>\n",
       "      <td>CCSC(=O)N(CC)C1CCCCC1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>2,6-Dimethylpyridine</td>\n",
       "      <td>-2.098</td>\n",
       "      <td>1</td>\n",
       "      <td>107.156</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>12.89</td>\n",
       "      <td>0.450</td>\n",
       "      <td>Cc1cccc(C)n1</td>\n",
       "      <td>Cc1cccc(C)n1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97</th>\n",
       "      <td>1,2-Dibromobenzene</td>\n",
       "      <td>-4.172</td>\n",
       "      <td>1</td>\n",
       "      <td>235.906</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-3.500</td>\n",
       "      <td>Brc1ccccc1Br</td>\n",
       "      <td>Brc1ccccc1Br</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>98</th>\n",
       "      <td>Hexestrol</td>\n",
       "      <td>-4.854</td>\n",
       "      <td>1</td>\n",
       "      <td>270.372</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>5</td>\n",
       "      <td>40.46</td>\n",
       "      <td>-4.430</td>\n",
       "      <td>CCC(C(CC)c1ccc(O)cc1)c2ccc(O)cc2</td>\n",
       "      <td>CCC(c1ccc(O)cc1)C(CC)c1ccc(O)cc1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>99</th>\n",
       "      <td>Ethyl formate</td>\n",
       "      <td>-0.402</td>\n",
       "      <td>1</td>\n",
       "      <td>74.079</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>26.30</td>\n",
       "      <td>0.150</td>\n",
       "      <td>CCOC=O</td>\n",
       "      <td>CCOC=O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>2,4,5-Trichlorophenol</td>\n",
       "      <td>-3.780</td>\n",
       "      <td>1</td>\n",
       "      <td>197.448</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>20.23</td>\n",
       "      <td>-2.210</td>\n",
       "      <td>Oc1cc(Cl)c(Cl)cc1Cl</td>\n",
       "      <td>Oc1cc(Cl)c(Cl)cc1Cl</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>triforine</td>\n",
       "      <td>-3.715</td>\n",
       "      <td>1</td>\n",
       "      <td>430.934</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>64.68</td>\n",
       "      <td>-4.190</td>\n",
       "      <td>ClC(Cl)(Cl)C(NC=O)N1C=CN(C=C1)C(NC=O)C(Cl)(Cl)Cl</td>\n",
       "      <td>O=CNC(N1C=CN(C(NC=O)C(Cl)(Cl)Cl)C=C1)C(Cl)(Cl)Cl</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>Metolachlor</td>\n",
       "      <td>-3.431</td>\n",
       "      <td>1</td>\n",
       "      <td>283.799</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>29.54</td>\n",
       "      <td>-2.730</td>\n",
       "      <td>CCc1cccc(C)c1N(C(C)COC)C(=O)CCl</td>\n",
       "      <td>CCc1cccc(C)c1N(C(=O)CCl)C(C)COC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>salicylanilide</td>\n",
       "      <td>-3.782</td>\n",
       "      <td>1</td>\n",
       "      <td>213.236</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>49.33</td>\n",
       "      <td>-3.590</td>\n",
       "      <td>c1ccccc1NC(=O)c2c(O)cccc2</td>\n",
       "      <td>O=C(Nc1ccccc1)c1ccccc1O</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>104</th>\n",
       "      <td>2-Chloronapthalene</td>\n",
       "      <td>-4.063</td>\n",
       "      <td>1</td>\n",
       "      <td>162.619</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-4.140</td>\n",
       "      <td>Clc1ccc2ccccc2c1</td>\n",
       "      <td>Clc1ccc2ccccc2c1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>105</th>\n",
       "      <td>Minoxidil</td>\n",
       "      <td>-1.809</td>\n",
       "      <td>1</td>\n",
       "      <td>209.253</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>95.11</td>\n",
       "      <td>-1.989</td>\n",
       "      <td>Nc1cc(nc(N)n1=O)N2CCCCC2</td>\n",
       "      <td>Nc1cc(N2CCCCC2)nc(N)[n+]1[O-]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>106</th>\n",
       "      <td>2-Chloropropane</td>\n",
       "      <td>-1.585</td>\n",
       "      <td>1</td>\n",
       "      <td>78.542</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-1.410</td>\n",
       "      <td>CC(C)Cl</td>\n",
       "      <td>CC(C)Cl</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>107</th>\n",
       "      <td>Ioxynil</td>\n",
       "      <td>-4.615</td>\n",
       "      <td>1</td>\n",
       "      <td>370.915</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>44.02</td>\n",
       "      <td>-3.610</td>\n",
       "      <td>Oc1c(I)cc(C#N)cc1I</td>\n",
       "      <td>N#Cc1cc(I)c(O)c(I)c1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>108</th>\n",
       "      <td>p-Hydroxybenzaldehyde</td>\n",
       "      <td>-2.003</td>\n",
       "      <td>1</td>\n",
       "      <td>122.123</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>37.30</td>\n",
       "      <td>-0.960</td>\n",
       "      <td>Oc1ccc(C=O)cc1</td>\n",
       "      <td>O=Cc1ccc(O)cc1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>109</th>\n",
       "      <td>Propyl propanoate</td>\n",
       "      <td>-1.545</td>\n",
       "      <td>1</td>\n",
       "      <td>116.160</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>26.30</td>\n",
       "      <td>-1.340</td>\n",
       "      <td>CCCCC(=O)OC</td>\n",
       "      <td>CCCCC(=O)OC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>110</th>\n",
       "      <td>Methylcyclopentane</td>\n",
       "      <td>-2.452</td>\n",
       "      <td>1</td>\n",
       "      <td>84.162</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-3.300</td>\n",
       "      <td>CC1CCCC1</td>\n",
       "      <td>CC1CCCC1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>111</th>\n",
       "      <td>Dimethyldisulfide</td>\n",
       "      <td>-1.524</td>\n",
       "      <td>1</td>\n",
       "      <td>94.204</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0.00</td>\n",
       "      <td>-1.440</td>\n",
       "      <td>CSSC</td>\n",
       "      <td>CSSC</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>112</th>\n",
       "      <td>Pentobarbital</td>\n",
       "      <td>-2.312</td>\n",
       "      <td>1</td>\n",
       "      <td>226.276</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>75.27</td>\n",
       "      <td>-2.390</td>\n",
       "      <td>O=C1NC(=O)NC(=O)C1(CC)C(C)CCC</td>\n",
       "      <td>CCCC(C)C1(CC)C(=O)NC(=O)NC1=O</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>113 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Compound ID  \\\n",
       "0                1-Chlorobutane   \n",
       "1            2,6-Dimethylphenol   \n",
       "2                        RTI 24   \n",
       "3                   1-Dodecanol   \n",
       "4                    3-Pentanol   \n",
       "5                     Dimefuron   \n",
       "6                  8-quinolinol   \n",
       "7                  Fenitrothion   \n",
       "8                   Tetradecane   \n",
       "9             4-hydroxypyridine   \n",
       "10                      Pyrolan   \n",
       "11                 Androsterone   \n",
       "12                      Styrene   \n",
       "13                   Erythritol   \n",
       "14               1-Tetradecanol   \n",
       "15                Butyraldehyde   \n",
       "16   1,2,4,5-Tetramethylbenzene   \n",
       "17                   Coumachlor   \n",
       "18                    Fenarimol   \n",
       "19          hydrochlorothiazide   \n",
       "20             Methyl nonanoate   \n",
       "21                      meconin   \n",
       "22                     1-Hexene   \n",
       "23                 Glutethimide   \n",
       "24           3-Methyl-3-hexanol   \n",
       "25               4-Ethyltoluene   \n",
       "26                  metharbital   \n",
       "27                   Piperophos   \n",
       "28                  Bromoethane   \n",
       "29                    3-Octanol   \n",
       "..                          ...   \n",
       "83                    thiamylal   \n",
       "84           Diisopropylsulfide   \n",
       "85                  Procymidone   \n",
       "86                1-Bromobutane   \n",
       "87          1,2-Diethoxyethane    \n",
       "88                  Thalidomide   \n",
       "89                   1-Pentene    \n",
       "90                 Propetamphos   \n",
       "91      triamcinolone diacetate   \n",
       "92               4-Pentene-1-ol   \n",
       "93              3-Methylheptane   \n",
       "94         o-Chlorobromobenzene   \n",
       "95                     cycloate   \n",
       "96         2,6-Dimethylpyridine   \n",
       "97           1,2-Dibromobenzene   \n",
       "98                    Hexestrol   \n",
       "99                Ethyl formate   \n",
       "100      2,4,5-Trichlorophenol    \n",
       "101                   triforine   \n",
       "102                 Metolachlor   \n",
       "103              salicylanilide   \n",
       "104          2-Chloronapthalene   \n",
       "105                   Minoxidil   \n",
       "106             2-Chloropropane   \n",
       "107                     Ioxynil   \n",
       "108      p-Hydroxybenzaldehyde    \n",
       "109           Propyl propanoate   \n",
       "110          Methylcyclopentane   \n",
       "111           Dimethyldisulfide   \n",
       "112               Pentobarbital   \n",
       "\n",
       "     ESOL predicted log solubility in mols per litre  Minimum Degree  \\\n",
       "0                                             -1.940               1   \n",
       "1                                             -2.589               1   \n",
       "2                                             -4.423               1   \n",
       "3                                             -3.523               1   \n",
       "4                                             -0.970               1   \n",
       "5                                             -3.831               1   \n",
       "6                                             -2.725               1   \n",
       "7                                             -3.845               1   \n",
       "8                                             -5.450               1   \n",
       "9                                             -1.655               1   \n",
       "10                                            -3.141               1   \n",
       "11                                            -3.882               1   \n",
       "12                                            -2.850               1   \n",
       "13                                             0.675               1   \n",
       "14                                            -4.231               1   \n",
       "15                                            -0.749               1   \n",
       "16                                            -3.664               1   \n",
       "17                                            -4.554               1   \n",
       "18                                            -4.108               1   \n",
       "19                                            -1.720               1   \n",
       "20                                            -2.962               1   \n",
       "21                                            -0.825               1   \n",
       "22                                            -2.364               1   \n",
       "23                                            -2.591               1   \n",
       "24                                            -1.663               1   \n",
       "25                                            -3.328               1   \n",
       "26                                            -1.658               1   \n",
       "27                                            -4.637               1   \n",
       "28                                            -1.529               1   \n",
       "29                                            -2.033               1   \n",
       "..                                               ...             ...   \n",
       "83                                            -3.063               1   \n",
       "84                                            -2.162               1   \n",
       "85                                            -3.464               1   \n",
       "86                                            -2.303               1   \n",
       "87                                            -0.833               1   \n",
       "88                                            -1.944               1   \n",
       "89                                            -2.010               1   \n",
       "90                                            -2.826               1   \n",
       "91                                            -3.876               1   \n",
       "92                                            -0.791               1   \n",
       "93                                            -3.308               1   \n",
       "94                                            -3.840               1   \n",
       "95                                            -3.350               1   \n",
       "96                                            -2.098               1   \n",
       "97                                            -4.172               1   \n",
       "98                                            -4.854               1   \n",
       "99                                            -0.402               1   \n",
       "100                                           -3.780               1   \n",
       "101                                           -3.715               1   \n",
       "102                                           -3.431               1   \n",
       "103                                           -3.782               1   \n",
       "104                                           -4.063               1   \n",
       "105                                           -1.809               1   \n",
       "106                                           -1.585               1   \n",
       "107                                           -4.615               1   \n",
       "108                                           -2.003               1   \n",
       "109                                           -1.545               1   \n",
       "110                                           -2.452               1   \n",
       "111                                           -1.524               1   \n",
       "112                                           -2.312               1   \n",
       "\n",
       "     Molecular Weight  Number of H-Bond Donors  Number of Rings  \\\n",
       "0              92.569                        0                0   \n",
       "1             122.167                        1                1   \n",
       "2             273.723                        1                3   \n",
       "3             186.339                        1                0   \n",
       "4              88.150                        1                0   \n",
       "5             338.795                        1                2   \n",
       "6             145.161                        1                2   \n",
       "7             277.238                        0                1   \n",
       "8             198.394                        0                0   \n",
       "9              95.101                        1                1   \n",
       "10            245.282                        0                2   \n",
       "11            290.447                        1                4   \n",
       "12            104.152                        0                1   \n",
       "13            122.120                        4                0   \n",
       "14            214.393                        1                0   \n",
       "15             72.107                        0                0   \n",
       "16            134.222                        0                1   \n",
       "17            342.778                        1                3   \n",
       "18            331.202                        1                3   \n",
       "19            297.745                        3                2   \n",
       "20            172.268                        0                0   \n",
       "21            196.202                        0                2   \n",
       "22             84.162                        0                0   \n",
       "23            217.268                        1                2   \n",
       "24            116.204                        1                0   \n",
       "25            120.195                        0                1   \n",
       "26            198.222                        1                1   \n",
       "27            353.490                        0                1   \n",
       "28            108.966                        0                0   \n",
       "29            130.231                        1                0   \n",
       "..                ...                      ...              ...   \n",
       "83            254.355                        2                1   \n",
       "84            118.245                        0                0   \n",
       "85            284.142                        0                3   \n",
       "86            137.020                        0                0   \n",
       "87            118.176                        0                0   \n",
       "88            258.233                        1                3   \n",
       "89             70.135                        0                0   \n",
       "90            281.314                        1                0   \n",
       "91            478.513                        2                4   \n",
       "92             86.134                        1                0   \n",
       "93            114.232                        0                0   \n",
       "94            191.455                        0                1   \n",
       "95            215.362                        0                1   \n",
       "96            107.156                        0                1   \n",
       "97            235.906                        0                1   \n",
       "98            270.372                        2                2   \n",
       "99             74.079                        0                0   \n",
       "100           197.448                        1                1   \n",
       "101           430.934                        2                1   \n",
       "102           283.799                        0                1   \n",
       "103           213.236                        2                2   \n",
       "104           162.619                        0                2   \n",
       "105           209.253                        2                2   \n",
       "106            78.542                        0                0   \n",
       "107           370.915                        1                1   \n",
       "108           122.123                        1                1   \n",
       "109           116.160                        0                0   \n",
       "110            84.162                        0                1   \n",
       "111            94.204                        0                0   \n",
       "112           226.276                        2                1   \n",
       "\n",
       "     Number of Rotatable Bonds  Polar Surface Area  \\\n",
       "0                            2                0.00   \n",
       "1                            0               20.23   \n",
       "2                            1               45.23   \n",
       "3                           10               20.23   \n",
       "4                            2               20.23   \n",
       "5                            2               80.37   \n",
       "6                            0               33.12   \n",
       "7                            5               70.83   \n",
       "8                           11                0.00   \n",
       "9                            0               33.12   \n",
       "10                           2               47.36   \n",
       "11                           0               37.30   \n",
       "12                           1                0.00   \n",
       "13                           3               80.92   \n",
       "14                          12               20.23   \n",
       "15                           2               17.07   \n",
       "16                           0                0.00   \n",
       "17                           4               67.51   \n",
       "18                           3               46.01   \n",
       "19                           1              118.36   \n",
       "20                           7               26.30   \n",
       "21                           2               44.76   \n",
       "22                           3                0.00   \n",
       "23                           2               46.17   \n",
       "24                           3               20.23   \n",
       "25                           1                0.00   \n",
       "26                           2               66.48   \n",
       "27                           9               38.77   \n",
       "28                           0                0.00   \n",
       "29                           5               20.23   \n",
       "..                         ...                 ...   \n",
       "83                           5               58.20   \n",
       "84                           2                0.00   \n",
       "85                           1               37.38   \n",
       "86                           2                0.00   \n",
       "87                           5               18.46   \n",
       "88                           1               83.55   \n",
       "89                           2                0.00   \n",
       "90                           7               56.79   \n",
       "91                           4              127.20   \n",
       "92                           3               20.23   \n",
       "93                           4                0.00   \n",
       "94                           0                0.00   \n",
       "95                           3               20.31   \n",
       "96                           0               12.89   \n",
       "97                           0                0.00   \n",
       "98                           5               40.46   \n",
       "99                           2               26.30   \n",
       "100                          0               20.23   \n",
       "101                          6               64.68   \n",
       "102                          6               29.54   \n",
       "103                          2               49.33   \n",
       "104                          0                0.00   \n",
       "105                          1               95.11   \n",
       "106                          0                0.00   \n",
       "107                          0               44.02   \n",
       "108                          1               37.30   \n",
       "109                          3               26.30   \n",
       "110                          0                0.00   \n",
       "111                          1                0.00   \n",
       "112                          4               75.27   \n",
       "\n",
       "     measured log solubility in mols per litre  \\\n",
       "0                                       -2.030   \n",
       "1                                       -1.290   \n",
       "2                                       -5.360   \n",
       "3                                       -4.800   \n",
       "4                                       -0.240   \n",
       "5                                       -4.328   \n",
       "6                                       -2.420   \n",
       "7                                       -4.040   \n",
       "8                                       -7.960   \n",
       "9                                        1.020   \n",
       "10                                      -2.090   \n",
       "11                                      -4.402   \n",
       "12                                      -2.820   \n",
       "13                                       0.700   \n",
       "14                                      -5.840   \n",
       "15                                      -0.010   \n",
       "16                                      -4.590   \n",
       "17                                      -5.839   \n",
       "18                                      -4.380   \n",
       "19                                      -2.630   \n",
       "20                                      -3.380   \n",
       "21                                      -1.899   \n",
       "22                                      -3.230   \n",
       "23                                      -2.337   \n",
       "24                                      -0.980   \n",
       "25                                      -3.110   \n",
       "26                                      -2.230   \n",
       "27                                      -4.150   \n",
       "28                                      -1.090   \n",
       "29                                      -1.980   \n",
       "..                                         ...   \n",
       "83                                      -3.460   \n",
       "84                                      -2.240   \n",
       "85                                      -4.800   \n",
       "86                                      -2.370   \n",
       "87                                      -0.770   \n",
       "88                                      -2.676   \n",
       "89                                      -2.680   \n",
       "90                                      -3.408   \n",
       "91                                      -4.130   \n",
       "92                                      -0.150   \n",
       "93                                      -5.160   \n",
       "94                                      -3.190   \n",
       "95                                      -3.400   \n",
       "96                                       0.450   \n",
       "97                                      -3.500   \n",
       "98                                      -4.430   \n",
       "99                                       0.150   \n",
       "100                                     -2.210   \n",
       "101                                     -4.190   \n",
       "102                                     -2.730   \n",
       "103                                     -3.590   \n",
       "104                                     -4.140   \n",
       "105                                     -1.989   \n",
       "106                                     -1.410   \n",
       "107                                     -3.610   \n",
       "108                                     -0.960   \n",
       "109                                     -1.340   \n",
       "110                                     -3.300   \n",
       "111                                     -1.440   \n",
       "112                                     -2.390   \n",
       "\n",
       "                                                smiles  \\\n",
       "0                                               CCCCCl   \n",
       "1                                        Cc1cccc(C)c1O   \n",
       "2                     CCN2c1cc(Cl)ccc1NC(=O)c3cccnc23    \n",
       "3                                        CCCCCCCCCCCCO   \n",
       "4                                             CCC(O)CC   \n",
       "5         CN(C)C(=O)Nc1ccc(c(Cl)c1)n2nc(oc2=O)C(C)(C)C   \n",
       "6                                     Oc1cccc2cccnc12    \n",
       "7                     COP(=S)(OC)Oc1ccc(N(=O)=O)c(C)c1   \n",
       "8                                       CCCCCCCCCCCCCC   \n",
       "9                                            Oc1ccncc1   \n",
       "10                       CN(C)C(=O)Oc1cc(C)nn1c2ccccc2   \n",
       "11                  CC12CCC(O)CC1CCC3C2CCC4(C)C3CCC4=O   \n",
       "12                                         C=Cc1ccccc1   \n",
       "13                                        OCC(O)C(O)CO   \n",
       "14                                     CCCCCCCCCCCCCCO   \n",
       "15                                              CCCC=O   \n",
       "16                                    Cc1cc(C)c(C)cc1C   \n",
       "17           CC(=O)CC(c1ccc(Cl)cc1)c2c(O)c3ccccc3oc2=O   \n",
       "18                OC(c1ccc(Cl)cc1)(c2cncnc2)c3ccccc3Cl   \n",
       "19                 NS(=O)(=O)c2cc1c(NCNS1(=O)=O)cc2Cl    \n",
       "20                                     CCCCCCCCC(=O)OC   \n",
       "21                           c1c(OC)c(OC)C2C(=O)OCC2c1   \n",
       "22                                             CCCCC=C   \n",
       "23                         CCC1(CCC(=O)NC1=O)c2ccccc2    \n",
       "24                                        CCCC(C)(O)CC   \n",
       "25                                       CCc1ccc(C)cc1   \n",
       "26                        CCC1(CC)C(=O)NC(=O)N(C)C1=O    \n",
       "27                     CCCOP(=S)(OCCC)SCC(=O)N1CCCCC1C   \n",
       "28                                                CCBr   \n",
       "29                                         CCCCCC(O)CC   \n",
       "..                                                 ...   \n",
       "83                    CCCC(C)C1(CC=C)C(=O)NC(=S)NC1=O    \n",
       "84                                         CC(C)SC(C)C   \n",
       "85              CC12CC2(C)C(=O)N(C1=O)c3cc(Cl)cc(Cl)c3   \n",
       "86                                              CCCCBr   \n",
       "87                                            CCOCCOCC   \n",
       "88                 O=C1N(C2CCC(=O)NC2=O)C(=O)c3ccccc13   \n",
       "89                                              CCCC=C   \n",
       "90                      CCNP(=S)(OC)OC(=CC(=O)OC(C)C)C   \n",
       "91   CC(=O)OCC(=O)C3(O)C(CC4C2CCC1=CC(=O)C=CC1(C)C2...   \n",
       "92                                             OCCCC=C   \n",
       "93                                          CCCCC(C)CC   \n",
       "94                                        Clc1ccccc1Br   \n",
       "95                              CCSC(=O)N(CC)C1CCCCC1    \n",
       "96                                        Cc1cccc(C)n1   \n",
       "97                                        Brc1ccccc1Br   \n",
       "98                    CCC(C(CC)c1ccc(O)cc1)c2ccc(O)cc2   \n",
       "99                                              CCOC=O   \n",
       "100                                Oc1cc(Cl)c(Cl)cc1Cl   \n",
       "101  ClC(Cl)(Cl)C(NC=O)N1C=CN(C=C1)C(NC=O)C(Cl)(Cl)Cl    \n",
       "102                   CCc1cccc(C)c1N(C(C)COC)C(=O)CCl    \n",
       "103                          c1ccccc1NC(=O)c2c(O)cccc2   \n",
       "104                                   Clc1ccc2ccccc2c1   \n",
       "105                          Nc1cc(nc(N)n1=O)N2CCCCC2    \n",
       "106                                            CC(C)Cl   \n",
       "107                                 Oc1c(I)cc(C#N)cc1I   \n",
       "108                                     Oc1ccc(C=O)cc1   \n",
       "109                                        CCCCC(=O)OC   \n",
       "110                                           CC1CCCC1   \n",
       "111                                               CSSC   \n",
       "112                      O=C1NC(=O)NC(=O)C1(CC)C(C)CCC   \n",
       "\n",
       "                                           cano_smiles  \n",
       "0                                               CCCCCl  \n",
       "1                                        Cc1cccc(C)c1O  \n",
       "2                      CCN1c2cc(Cl)ccc2NC(=O)c2cccnc21  \n",
       "3                                        CCCCCCCCCCCCO  \n",
       "4                                             CCC(O)CC  \n",
       "5        CN(C)C(=O)Nc1ccc(-n2nc(C(C)(C)C)oc2=O)c(Cl)c1  \n",
       "6                                      Oc1cccc2cccnc12  \n",
       "7                COP(=S)(OC)Oc1ccc([N+](=O)[O-])c(C)c1  \n",
       "8                                       CCCCCCCCCCCCCC  \n",
       "9                                            Oc1ccncc1  \n",
       "10                    Cc1cc(OC(=O)N(C)C)n(-c2ccccc2)n1  \n",
       "11                  CC12CCC3C(CCC4CC(O)CCC43C)C1CCC2=O  \n",
       "12                                         C=Cc1ccccc1  \n",
       "13                                        OCC(O)C(O)CO  \n",
       "14                                     CCCCCCCCCCCCCCO  \n",
       "15                                              CCCC=O  \n",
       "16                                    Cc1cc(C)c(C)cc1C  \n",
       "17           CC(=O)CC(c1ccc(Cl)cc1)c1c(O)c2ccccc2oc1=O  \n",
       "18                OC(c1ccc(Cl)cc1)(c1cncnc1)c1ccccc1Cl  \n",
       "19                  NS(=O)(=O)c1cc2c(cc1Cl)NCNS2(=O)=O  \n",
       "20                                     CCCCCCCCC(=O)OC  \n",
       "21                           COC1=C(OC)C2C(=O)OCC2C=C1  \n",
       "22                                             C=CCCCC  \n",
       "23                          CCC1(c2ccccc2)CCC(=O)NC1=O  \n",
       "24                                        CCCC(C)(O)CC  \n",
       "25                                       CCc1ccc(C)cc1  \n",
       "26                         CCC1(CC)C(=O)NC(=O)N(C)C1=O  \n",
       "27                     CCCOP(=S)(OCCC)SCC(=O)N1CCCCC1C  \n",
       "28                                                CCBr  \n",
       "29                                         CCCCCC(O)CC  \n",
       "..                                                 ...  \n",
       "83                     C=CCC1(C(C)CCC)C(=O)NC(=S)NC1=O  \n",
       "84                                         CC(C)SC(C)C  \n",
       "85              CC12CC1(C)C(=O)N(c1cc(Cl)cc(Cl)c1)C2=O  \n",
       "86                                              CCCCBr  \n",
       "87                                            CCOCCOCC  \n",
       "88                 O=C1CCC(N2C(=O)c3ccccc3C2=O)C(=O)N1  \n",
       "89                                              C=CCCC  \n",
       "90                      CCNP(=S)(OC)OC(C)=CC(=O)OC(C)C  \n",
       "91   CC(=O)OCC(=O)C1(O)C(OC(C)=O)CC2C3CCC4=CC(=O)C=...  \n",
       "92                                             C=CCCCO  \n",
       "93                                          CCCCC(C)CC  \n",
       "94                                        Clc1ccccc1Br  \n",
       "95                               CCSC(=O)N(CC)C1CCCCC1  \n",
       "96                                        Cc1cccc(C)n1  \n",
       "97                                        Brc1ccccc1Br  \n",
       "98                    CCC(c1ccc(O)cc1)C(CC)c1ccc(O)cc1  \n",
       "99                                              CCOC=O  \n",
       "100                                Oc1cc(Cl)c(Cl)cc1Cl  \n",
       "101   O=CNC(N1C=CN(C(NC=O)C(Cl)(Cl)Cl)C=C1)C(Cl)(Cl)Cl  \n",
       "102                    CCc1cccc(C)c1N(C(=O)CCl)C(C)COC  \n",
       "103                            O=C(Nc1ccccc1)c1ccccc1O  \n",
       "104                                   Clc1ccc2ccccc2c1  \n",
       "105                      Nc1cc(N2CCCCC2)nc(N)[n+]1[O-]  \n",
       "106                                            CC(C)Cl  \n",
       "107                               N#Cc1cc(I)c(O)c(I)c1  \n",
       "108                                     O=Cc1ccc(O)cc1  \n",
       "109                                        CCCCC(=O)OC  \n",
       "110                                           CC1CCCC1  \n",
       "111                                               CSSC  \n",
       "112                      CCCC(C)C1(CC)C(=O)NC(=O)NC1=O  \n",
       "\n",
       "[113 rows x 11 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "863604\n",
      "atom_fc.weight torch.Size([200, 39])\n",
      "atom_fc.bias torch.Size([200])\n",
      "neighbor_fc.weight torch.Size([200, 49])\n",
      "neighbor_fc.bias torch.Size([200])\n",
      "GRUCell.0.weight_ih torch.Size([600, 200])\n",
      "GRUCell.0.weight_hh torch.Size([600, 200])\n",
      "GRUCell.0.bias_ih torch.Size([600])\n",
      "GRUCell.0.bias_hh torch.Size([600])\n",
      "GRUCell.1.weight_ih torch.Size([600, 200])\n",
      "GRUCell.1.weight_hh torch.Size([600, 200])\n",
      "GRUCell.1.bias_ih torch.Size([600])\n",
      "GRUCell.1.bias_hh torch.Size([600])\n",
      "align.0.weight torch.Size([1, 400])\n",
      "align.0.bias torch.Size([1])\n",
      "align.1.weight torch.Size([1, 400])\n",
      "align.1.bias torch.Size([1])\n",
      "attend.0.weight torch.Size([200, 200])\n",
      "attend.0.bias torch.Size([200])\n",
      "attend.1.weight torch.Size([200, 200])\n",
      "attend.1.bias torch.Size([200])\n",
      "mol_GRUCell.weight_ih torch.Size([600, 200])\n",
      "mol_GRUCell.weight_hh torch.Size([600, 200])\n",
      "mol_GRUCell.bias_ih torch.Size([600])\n",
      "mol_GRUCell.bias_hh torch.Size([600])\n",
      "mol_align.weight torch.Size([1, 400])\n",
      "mol_align.bias torch.Size([1])\n",
      "mol_attend.weight torch.Size([200, 200])\n",
      "mol_attend.bias torch.Size([200])\n",
      "output.weight torch.Size([1, 200])\n",
      "output.bias torch.Size([1])\n"
     ]
    }
   ],
   "source": [
    "x_atom, x_bonds, x_atom_index, x_bond_index, x_mask, smiles_to_rdkit_list = get_smiles_array([canonical_smiles_list[0]],feature_dicts)\n",
    "num_atom_features = x_atom.shape[-1]\n",
    "num_bond_features = x_bonds.shape[-1]\n",
    "loss_function = nn.MSELoss()\n",
    "model = Fingerprint(radius, T, num_atom_features, num_bond_features,\n",
    "            fingerprint_dim, output_units_num, p_dropout)\n",
    "model.cuda()\n",
    "\n",
    "# optimizer = optim.Adam(model.parameters(), learning_rate, weight_decay=weight_decay)\n",
    "optimizer = optim.Adam(model.parameters(), 10**-learning_rate, weight_decay=10**-weight_decay)\n",
    "# optimizer = optim.SGD(model.parameters(), 10**-learning_rate, weight_decay=10**-weight_decay)\n",
    "\n",
    "# tensorboard = SummaryWriter(log_dir=\"runs/\"+start_time+\"_\"+prefix_filename+\"_\"+str(fingerprint_dim)+\"_\"+str(p_dropout))\n",
    "\n",
    "model_parameters = filter(lambda p: p.requires_grad, model.parameters())\n",
    "params = sum([np.prod(p.size()) for p in model_parameters])\n",
    "print(params)\n",
    "for name, param in model.named_parameters():\n",
    "    if param.requires_grad:\n",
    "        print(name, param.data.shape)\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "def train(model, dataset, optimizer, loss_function):\n",
    "    model.train()\n",
    "    np.random.seed(epoch)\n",
    "    valList = np.arange(0,dataset.shape[0])\n",
    "    #shuffle them\n",
    "    np.random.shuffle(valList)\n",
    "    batch_list = []\n",
    "    for i in range(0, dataset.shape[0], batch_size):\n",
    "        batch = valList[i:i+batch_size]\n",
    "        batch_list.append(batch)   \n",
    "    for counter, train_batch in enumerate(batch_list):\n",
    "        batch_df = dataset.loc[train_batch,:]\n",
    "        smiles_list = batch_df.cano_smiles.values\n",
    "        y_val = batch_df[tasks[0]].values\n",
    "        \n",
    "        x_atom, x_bonds, x_atom_index, x_bond_index, x_mask, smiles_to_rdkit_list = get_smiles_array(smiles_list,feature_dicts)\n",
    "        atoms_prediction, mol_prediction = model(torch.Tensor(x_atom),torch.Tensor(x_bonds),torch.cuda.LongTensor(x_atom_index),torch.cuda.LongTensor(x_bond_index),torch.Tensor(x_mask))\n",
    "        \n",
    "        model.zero_grad()\n",
    "        loss = loss_function(mol_prediction, torch.Tensor(y_val).view(-1,1))     \n",
    "        loss.backward()\n",
    "        optimizer.step()\n",
    "def eval(model, dataset):\n",
    "    model.eval()\n",
    "    test_MAE_list = []\n",
    "    test_MSE_list = []\n",
    "    valList = np.arange(0,dataset.shape[0])\n",
    "    batch_list = []\n",
    "    for i in range(0, dataset.shape[0], batch_size):\n",
    "        batch = valList[i:i+batch_size]\n",
    "        batch_list.append(batch) \n",
    "    for counter, test_batch in enumerate(batch_list):\n",
    "        batch_df = dataset.loc[test_batch,:]\n",
    "        smiles_list = batch_df.cano_smiles.values\n",
    "#         print(batch_df)\n",
    "        y_val = batch_df[tasks[0]].values\n",
    "        \n",
    "        x_atom, x_bonds, x_atom_index, x_bond_index, x_mask, smiles_to_rdkit_list = get_smiles_array(smiles_list,feature_dicts)\n",
    "        atoms_prediction, mol_prediction = model(torch.Tensor(x_atom),torch.Tensor(x_bonds),torch.cuda.LongTensor(x_atom_index),torch.cuda.LongTensor(x_bond_index),torch.Tensor(x_mask))\n",
    "        MAE = F.l1_loss(mol_prediction, torch.Tensor(y_val).view(-1,1), reduction='none')        \n",
    "        MSE = F.mse_loss(mol_prediction, torch.Tensor(y_val).view(-1,1), reduction='none')\n",
    "#         print(x_mask[:2],atoms_prediction.shape, mol_prediction,MSE)\n",
    "        \n",
    "        test_MAE_list.extend(MAE.data.squeeze().cpu().numpy())\n",
    "        test_MSE_list.extend(MSE.data.squeeze().cpu().numpy())\n",
    "    return np.array(test_MAE_list).mean(), np.array(test_MSE_list).mean()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 3.7859693 3.9207678\n",
      "1 2.621496 2.6468432\n",
      "2 1.8796034 1.8596922\n",
      "3 1.7676139 1.7141385\n",
      "4 1.73025 1.6957797\n",
      "5 1.6362684 1.6309327\n",
      "6 1.5289621 1.5261148\n",
      "7 1.3922479 1.4023384\n",
      "8 1.1592052 1.1206535\n",
      "9 1.0223268 1.061162\n",
      "10 0.98977643 1.0626643\n",
      "11 0.9177827 0.937801\n",
      "12 0.8580692 0.88518524\n",
      "13 0.8087569 0.81720716\n",
      "14 0.8165224 0.8147224\n",
      "15 0.81199634 0.8063945\n",
      "16 0.7425832 0.7467531\n",
      "17 0.73987365 0.7912908\n",
      "18 0.7050149 0.7451038\n",
      "19 0.7058362 0.7928753\n",
      "20 0.71746725 0.8318719\n",
      "21 0.6533209 0.7296591\n",
      "22 0.64977115 0.71868986\n",
      "23 0.6545905 0.7144704\n",
      "24 0.6223205 0.7155877\n",
      "25 0.61187345 0.72389007\n",
      "26 0.64181405 0.77254975\n",
      "27 0.6363094 0.725399\n",
      "28 0.6333247 0.70250714\n",
      "29 0.6394508 0.70172536\n",
      "30 0.631363 0.6972769\n",
      "31 0.5732713 0.7165308\n",
      "32 0.581468 0.7327004\n",
      "33 0.55768543 0.6877764\n",
      "34 0.56602633 0.6715087\n",
      "35 0.55454886 0.6851089\n",
      "36 0.5387976 0.6608253\n",
      "37 0.542362 0.67119354\n",
      "38 0.54038894 0.64148605\n",
      "39 0.5256341 0.66760015\n",
      "40 0.5497973 0.6673351\n",
      "41 0.5331612 0.6707743\n",
      "42 0.53163403 0.6912205\n",
      "43 0.5040219 0.62359524\n",
      "44 0.51473236 0.62983143\n",
      "45 0.5623976 0.65332985\n",
      "46 0.5514217 0.64969784\n",
      "47 0.506393 0.61834055\n",
      "48 0.47938818 0.6111363\n",
      "49 0.5227146 0.68288076\n",
      "50 0.55725056 0.70770866\n",
      "51 0.4653488 0.59168434\n",
      "52 0.49626556 0.6568456\n",
      "53 0.4948499 0.6528563\n",
      "54 0.45749646 0.5984215\n",
      "55 0.50775075 0.60565907\n",
      "56 0.4900947 0.59085524\n",
      "57 0.4705982 0.58164716\n",
      "58 0.43681356 0.5858887\n",
      "59 0.44157937 0.6111552\n",
      "60 0.43919408 0.5890135\n",
      "61 0.46032816 0.6309343\n",
      "62 0.46972194 0.63861793\n",
      "63 0.4246726 0.5679724\n",
      "64 0.47899425 0.5936132\n",
      "65 0.46525288 0.59258455\n",
      "66 0.46583712 0.56712395\n",
      "67 0.46929827 0.58624357\n",
      "68 0.4668445 0.59316015\n",
      "69 0.44850594 0.56299704\n",
      "70 0.44658706 0.5701989\n",
      "71 0.46343037 0.5928269\n",
      "72 0.43927157 0.5672761\n",
      "73 0.40005195 0.5600078\n",
      "74 0.43330005 0.6056884\n",
      "75 0.45696825 0.60909796\n",
      "76 0.42903367 0.6024857\n",
      "77 0.43339348 0.6384431\n",
      "78 0.40957254 0.5691334\n",
      "79 0.4069046 0.55775076\n",
      "80 0.4029307 0.55177647\n",
      "81 0.4431365 0.56643623\n",
      "82 0.42683643 0.5712728\n",
      "83 0.40938458 0.5586055\n",
      "84 0.39260423 0.552013\n",
      "85 0.40093684 0.5617116\n",
      "86 0.38374332 0.5786578\n",
      "87 0.3672284 0.56557536\n",
      "88 0.3643836 0.5466154\n",
      "89 0.35685137 0.5520318\n",
      "90 0.35203704 0.57460284\n",
      "91 0.38007918 0.62180704\n",
      "92 0.39536464 0.6449521\n",
      "93 0.37351036 0.5898323\n",
      "94 0.34572342 0.5786129\n",
      "95 0.3570598 0.60194576\n",
      "96 0.3878782 0.607206\n",
      "97 0.36614 0.59064025\n",
      "98 0.3887454 0.5935917\n",
      "99 0.3560852 0.59423363\n",
      "100 0.34197813 0.5545293\n",
      "101 0.3375649 0.5535909\n",
      "102 0.34154037 0.5213054\n",
      "103 0.3868348 0.56327313\n",
      "104 0.43167242 0.5786155\n",
      "105 0.43979347 0.5910559\n",
      "106 0.42431602 0.5756407\n",
      "107 0.36694896 0.55186373\n",
      "108 0.35555333 0.5458485\n",
      "109 0.33638406 0.55612993\n",
      "110 0.31071386 0.5471849\n",
      "111 0.3065348 0.54155535\n",
      "112 0.30251393 0.5393234\n",
      "113 0.29828593 0.5337747\n",
      "114 0.31019717 0.54825157\n",
      "115 0.3086988 0.5562015\n",
      "116 0.31931236 0.56455153\n",
      "117 0.3194764 0.57618564\n",
      "118 0.3149238 0.55517495\n",
      "119 0.309275 0.5354269\n",
      "120 0.3081688 0.5473536\n",
      "121 0.29205334 0.55913717\n",
      "122 0.29604936 0.555833\n",
      "123 0.3227383 0.61563617\n",
      "124 0.30536538 0.5577699\n",
      "125 0.28532398 0.5492369\n",
      "126 0.28339425 0.5607352\n",
      "127 0.27352592 0.5548542\n",
      "128 0.2864791 0.5612195\n",
      "129 0.3055824 0.55154747\n",
      "130 0.29037616 0.5919362\n",
      "131 0.30300662 0.5786823\n",
      "132 0.2807251 0.5589076\n",
      "133 0.31711 0.5564996\n",
      "134 0.37011784 0.5881703\n",
      "135 0.3319953 0.5689385\n"
     ]
    }
   ],
   "source": [
    "best_param ={}\n",
    "best_param[\"train_epoch\"] = 0\n",
    "best_param[\"valid_epoch\"] = 0\n",
    "best_param[\"train_MSE\"] = 9e8\n",
    "best_param[\"valid_MSE\"] = 9e8\n",
    "\n",
    "for epoch in range(800):\n",
    "    train_MAE, train_MSE = eval(model, train_df)\n",
    "    valid_MAE, valid_MSE = eval(model, valid_df)\n",
    "#     tensorboard.add_scalars('MAE',{'train_MAE':valid_MAE, 'test_MAE':valid_MSE}, epoch)\n",
    "#     tensorboard.add_scalars('MSE',{'train_MSE':valid_MAE, 'test_MSE':valid_MSE}, epoch)\n",
    "    if train_MSE < best_param[\"train_MSE\"]:\n",
    "        best_param[\"train_epoch\"] = epoch\n",
    "        best_param[\"train_MSE\"] = train_MSE\n",
    "    if valid_MSE < best_param[\"valid_MSE\"]:\n",
    "        best_param[\"valid_epoch\"] = epoch\n",
    "        best_param[\"valid_MSE\"] = valid_MSE\n",
    "        if valid_MSE < 0.35:\n",
    "             torch.save(model, 'saved_models/model_'+prefix_filename+'_'+start_time+'_'+str(epoch)+'.pt')\n",
    "    if (epoch - best_param[\"train_epoch\"] >8) and (epoch - best_param[\"valid_epoch\"] >10):        \n",
    "        break\n",
    "    print(epoch, np.sqrt(train_MSE), np.sqrt(valid_MSE))\n",
    "    \n",
    "    train(model, train_df, optimizer, loss_function)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "best epoch: 102 \n",
      " test RMSE: 0.48607394\n"
     ]
    }
   ],
   "source": [
    "# evaluate model\n",
    "best_model = torch.load('saved_models/model_'+prefix_filename+'_'+start_time+'_'+str(best_param[\"valid_epoch\"])+'.pt')     \n",
    "\n",
    "best_model_dict = best_model.state_dict()\n",
    "best_model_wts = copy.deepcopy(best_model_dict)\n",
    "\n",
    "model.load_state_dict(best_model_wts)\n",
    "(best_model.align[0].weight == model.align[0].weight).all()\n",
    "test_MAE, test_MSE = eval(model, test_df)\n",
    "print(\"best epoch:\",best_param[\"valid_epoch\"],\"\\n\",\"test RMSE:\",np.sqrt(test_MSE))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
